<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('人员信息')" />
    <th:block th:include="include :: select2-css" />
    <th:block th:include="include :: bootstrap-fileinput-css" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>姓名：</label>
                                <input autocomplete="off" type="text" name="name" required/>
                            </li>
                            <li>
                                <label>部门：</label>
                                <input autocomplete="off" type="text" name="dep" required/>
                            </li>
                            <li>
                                <label>职务：</label>
                                <input autocomplete="off" type="text" name="position" required/>
                            </li>
                            <li>
                                <label>政治面貌：</label>
                                <input autocomplete="off" type="text" name="politicsStatus" required/>
                            </li>
                            <li>
                                <label>参加工作时间：</label>
<!--                                <input autocomplete="off" class="time-input" type="text" placeholder="请填写日期" id="jobTime"  name="jobTime" />-->
                                <div class="input-daterange input-group"><!--time-input-->
                                    <input type="text" class="time-input" name="jobBeginTime" placeholder="请填写日期"/>
                                    <span>&nbsp;到&nbsp;</span>
                                    <input type="text" class="time-input" name="jobOverTime" placeholder="请填写日期"/>
                                </div>
                            </li>
                            <li>
                                <label>入司时间：</label>
<!--                                <input autocomplete="off" class="time-input" type="text" placeholder="请填写日期" id="companyTime"  name="companyTime" />-->
                                <div class="input-daterange input-group"><!--time-input-->
                                    <input type="text" class="time-input" name="companyBeginTime" placeholder="请填写日期"/>
                                    <span>&nbsp;到&nbsp;</span>
                                    <input type="text" class="time-input" name="companyOverTime" placeholder="请填写日期"/>
                                </div>
                            </li>
                            <li>
                                <label>状态：</label>
                                <select name="status" class="form-control" required>
                                    <option value="">请选择</option>
                                    <option value="1">正常</option>
                                    <option value="2">退休</option>
                                    <option value="3">离职</option>
                                    <option value="4">解聘</option>
                                </select>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="query()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>
            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="hrm:propertyInfo:add">
                    <i class="fa fa-plus"></i> 新增
                </a>
                <a class="btn btn-success single disabled" onclick="$.operate.edit()" shiro:hasPermission="hrm:propertyInfo:update">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="hrm:propertyInfo:delete">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-info" onclick="$.table.importExcel('importTpl')" shiro:hasPermission="hrm:propertyInfo:import">
                    <i class="fa fa-upload"></i> 导入
                </a>
                <a class="btn btn-warning" onclick="exportInfo()" shiro:hasPermission="hrm:propertyInfo:export">
                    <i class="fa fa-download"></i> 导出
                </a>
                <a class="btn btn-warning single disabled" onclick="openUpload()" shiro:hasPermission="hrm:propertyInfo:upload">
                    <i class="fa fa-upload "></i> 上传附件
                </a>
                <a class="btn btn-warning single disabled" onclick="downInfo()" shiro:hasPermission="hrm:propertyInfo:download">
                    <i class="fa fa-download "></i> 下载附件
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
     <th:block th:include="include :: footer" />
     <th:block th:include="include :: bootstrap-fileinput-js" />
     <th:block th:include="include :: select2-js" />
    <script th:inline="javascript">

        var prefix = ctx + "hrm/propertyInfo";

        $(function () {
        })

        function openUpload(){
            var rows = $.table.selectColumns("infoId");
            if (rows.length!=1){
                $.modal.alertWarning("请选择一条数据进行上传！");
                return;
            }
            var infoId = rows.join();
            $.modal.openTab("上传附件", prefix + "/toUpload/"+infoId);
        }

        function downInfo(){
            var rows = $.table.selectColumns("infoId");
            if (rows.length!=1){
                $.modal.alertWarning("请选择一条数据进行下载！");
                return;
            }
            var infoId = rows.join();
            $.modal.loading("正在下载请稍后...");
            $.post(prefix+"/downloadInfo",{"infoId":infoId},function (res) {
                if (res.code == web_status.SUCCESS) {
                    window.location.href = prefix + "/downloadInfo?fileName=" + encodeURI(res.data);
                } else if (res.code == web_status.WARNING) {
                    $.modal.alertWarning(res.msg);
                } else {
                    $.modal.alertError(res.msg);
                }
                $.modal.closeLoading();
            })
        }

        function exportInfo(){
            var rows=$.table.selectColumns(table.options.uniqueId);
            var msg = "确定导出所有" + table.options.modalName + "吗？"
            if(rows.length!=0){
                msg = "确定导出勾选的"+rows.length+"条数据吗？"
            }
            $.modal.confirm(msg, function() {
                var params = $("#" + table.options.id).bootstrapTable('getOptions');
                var dataParam = $("#formId").serializeArray();
                dataParam.push({ "name": "orderByColumn", "value": params.sortName });
                dataParam.push({ "name": "isAsc", "value": params.sortOrder });
                if(rows.length!=0){
                    dataParam.push({"name": "ids", "value": rows.join()});
                }
                $.modal.loading("正在导出数据，请稍后...");
                $.post(table.options.exportUrl, dataParam, function(result) {
                    if (result.code == web_status.SUCCESS) {
                        window.location.href = ctx + "common/download?fileName=" + encodeURI(result.msg) + "&delete=" + true;
                    } else if (result.code == web_status.WARNING) {
                        $.modal.alertWarning(result.msg)
                    } else {
                        $.modal.alertError(result.msg);
                    }
                    $.modal.closeLoading();
                });
            });
        }
        var options;
        function query() {
            if (options != null && options != undefined) {
                var params = $("#bootstrap-table").bootstrapTable('getOptions');
                $("#bootstrap-table").bootstrapTable('refresh', params);
            } else {
                options = {
                    url: prefix + "/list",
                    createUrl: prefix + "/add",
                    updateUrl: prefix + "/edit/{id}",
                    removeUrl: prefix + "/remove",
                    exportUrl: prefix + "/export",
                    importUrl: prefix + "/import",
                    importTemplateUrl: prefix + "/importTemplate",
                    uniqueId: "infoId",
                    modalName: "人员信息",
                    columns: [{
                        checkbox: true
                    },
                        {
                            field: 'infoId',
                            title: '人员信息Id',
                            visible: false
                        },
                        {
                            field: 'num',
                            title: '序号',
                            visible: false
                        },
                        {
                            field: 'name',
                            title: '姓名',
                        },
                        {
                            field: 'dep',
                            title: '部门'
                        },
                        {
                            field: 'position',
                            title: '职务'
                        },
                        {
                            field: 'idNumber',
                            title: '身份证号',
                        },
                        {
                            field: 'phoneNo',
                            title: '手机号'
                        },
                        {
                            field: 'school',
                            title: '学校'
                        },
                        {
                            field: 'major',
                            title: '学历'
                        },
                        {
                            field: 'diploma',
                            title: '学位'
                        },
                        {
                            field: 'socialSecurityId',
                            title: '社保卡卡号'
                        },
                        {
                            field: 'accFundId',
                            title: '公积金账号'
                        },
                        {
                            field: 'maritalStatus',
                            title: '婚姻状态',
                            formatter: function (value, row, index) {
                                if (row.maritalStatus == "1") {
                                    return '<span class="label label-primary">已婚</span>';
                                } else if (row.maritalStatus == "2") {
                                    return '<span class="label label-warning">未婚</span>';
                                } else if (row.maritalStatus == "3") {
                                    return '<span class="label label-warning">未知</span>';
                                }
                            }
                        },
                        {
                            field: 'jobTime',
                            title: '参加工作时间',
                            visible: false
                        },
                        {
                            field: 'companyTime',
                            title: '入司时间',
                            visible: false
                        },
                        {
                            field: 'qualifyCertificate',
                            title: '职业资格证书'
                        },
                        {
                            field: 'profession',
                            title: '职称'
                        },
                        {
                            field: 'politicsStatus',
                            title: '政治面貌'
                        },
                        {
                            field: 'partyTime',
                            title: '入党时间',
                            visible: false
                        },
                        {
                            field: 'fileCount',
                            title: '附件数'
                        },
                        {
                            field: 'status',
                            title: '状态',
                            formatter: function (value, row, index) {
                                if (row.status == "1") {
                                    return '<span class="label label-primary">正常</span>';
                                } else if (row.status == "2") {
                                    return '<span class="label label-warning">退休</span>';
                                } else if (row.status == "3") {
                                    return '<span class="label label-warning">离职</span>';
                                } else if (row.status == "4") {
                                    return '<span class="label label-warning">解聘</span>';
                                }
                            }
                        },
                        {
                            field: 'attachment',
                            title: '附件',
                            visible: false
                        },
                        {
                            field: 'comment',
                            title: '备注',
                            visible: true
                        }]
                };
                $.table.init(options);
            }
        }
    </script>
</body>

<!-- 导入区域 -->

<script id="importTpl" type="text/template">
    <form enctype="multipart/form-data" class="mt20 mb10">
        <div class="col-xs-offset-1">
            <input type="file" id="file" name="file"/>
            <div class="mt10 pt5">
                <a onclick="$.table.importTemplate()" class="btn btn-default btn-xs" shiro:hasPermission="hrm:propertyInfo:template"><i class="fa fa-file-excel-o"></i> 下载模板</a>
            </div>
            <font color="red" class="pull-left mt10">
                提示：仅允许导入“xls”或“xlsx”格式文件！！！
            </font>
        </div>
    </form>
</script>
</html>
